package com.jyw.business.comp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.jyw.common.core.domain.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jyw.common.annotation.Log;
import com.jyw.common.core.controller.BaseController;
import com.jyw.common.core.domain.AjaxResult;
import com.jyw.common.enums.BusinessType;
import com.jyw.business.comp.domain.CompSchedulePlan;
import com.jyw.business.comp.service.ICompSchedulePlanService;
import com.jyw.common.utils.poi.ExcelUtil;
import com.jyw.common.core.page.TableDataInfo;

/**
 * 综合-值班班次安排Controller
 * 
 * @author ruoyi
 * @date 2023-12-25
 */
@RestController
@RequestMapping("/comp/plan")
@Api(tags = "排班日历")
public class CompSchedulePlanController extends BaseController
{
    @Autowired
    private ICompSchedulePlanService compSchedulePlanService;

    /**
     * 查询综合-值班班次安排列表
     */
    @PreAuthorize("@ss.hasPermi('comp:plan:list')")
    @GetMapping("/list")
    public TableDataInfo<CompSchedulePlan> list(CompSchedulePlan compSchedulePlan)
    {
        startPage();
        List<CompSchedulePlan> list = compSchedulePlanService.selectCompSchedulePlanList(compSchedulePlan);
        return getDataTable(list);
    }

    /**
     * 导出综合-值班班次安排列表
     */
    @PreAuthorize("@ss.hasPermi('comp:plan:export')")
    @Log(title = "综合-值班班次安排", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CompSchedulePlan compSchedulePlan)
    {
        List<CompSchedulePlan> list = compSchedulePlanService.selectCompSchedulePlanList(compSchedulePlan);
        ExcelUtil<CompSchedulePlan> util = new ExcelUtil<CompSchedulePlan>(CompSchedulePlan.class);
        util.exportExcel(response, list, "综合-值班班次安排数据");
    }

    /**
     * 获取综合-值班班次安排详细信息
     */
    @PreAuthorize("@ss.hasPermi('comp:plan:query')")
    @GetMapping(value = "/{id}")
    public CommonResult<CompSchedulePlan> getInfo(@PathVariable("id") Long id)
    {
        return CommonResult.success(compSchedulePlanService.selectCompSchedulePlanById(id));
    }

    /**
     * 新增综合-值班班次安排
     */
    @PreAuthorize("@ss.hasPermi('comp:plan:add')")
    @Log(title = "综合-值班班次安排", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody CompSchedulePlan compSchedulePlan)
    {
        return CommonResult.success(compSchedulePlanService.insertCompSchedulePlan(compSchedulePlan));
    }

    /**
     * 修改综合-值班班次安排
     */
    @PreAuthorize("@ss.hasPermi('comp:plan:edit')")
    @Log(title = "综合-值班班次安排", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody CompSchedulePlan compSchedulePlan)
    {
        return CommonResult.success(compSchedulePlanService.updateCompSchedulePlan(compSchedulePlan));
    }

    /**
     * 删除综合-值班班次安排
     */
    @PreAuthorize("@ss.hasPermi('comp:plan:remove')")
    @Log(title = "综合-值班班次安排", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return CommonResult.success(compSchedulePlanService.deleteCompSchedulePlanByIds(ids));
    }
}
